param($Module = "PoshOnTap", $upgradeCode= [system.guid]"15a19363-7264-44f4-85d8-79639035dfdc")
Process {
    $module = Import-Module $Module -PassThru 
    $path = Split-Path $module.Path
    $files = ls $path |?{$_.Extension -notmatch ".msi|.ps1$|.zip"}
    $msi = "{0}\{1}_{2}.msi" -f $path, $module.Name, $module.Version.ToString()
    $zip = "{0}\{1}_{2}.zip" -f $path, $module.Name, $module.Version.ToString()

    #clean up
    $zip, $msi|?{Test-path $_}|Remove-Item 

    #
    #Build MSI
    #
    Add-Type -Path "C:\Users\glnsize\Documents\WixSharp\WixSharp.dll"
    $project = New-Object wixsharp.Project
    $project.Name = $module.Name
    $project.Manufacturer = "Get-Admin.com"
    $project.Version = $module.Version.ToString()
    $project.GUID = $module.Guid
    $project.ui = "WixUI_Minimal"
    $project.MajorUpgradeStrategy = [wixsharp.MajorUpgradeStrategy]::Default
	$project.UpgradeCode = $upgradeCode
	
    $dir = New-Object wixsharp.Dir( "%SystemFolder%\WindowsPowerShell\v1.0\Modules\$($module.Name)" )

    $dir.files = $files | %{
        New-Object wixsharp.File($_.FullName)
    }

    $project.Dirs = @( $dir )
	[wixsharp.Compiler]::BuildMsi( $project,  $msi)

    #
    Import-Module powershellpack -DisableNameChecking
    $zip =  New-Zip -Path $zip -PassThru
    Start-Sleep -Seconds 2
    $files|Copy-ToZip -ZipFile $zip -Force
	
	Remove-Module powershellpack
	Remove-Module $module
}